package com.sinosoft.ptas.service.impl;

import java.util.List;







import java.util.UUID;

import org.springframework.validation.annotation.Validated;

import com.sinosoft.framework.core.common.exception.BusinessException;
import com.sinosoft.framework.core.common.utils.StringUtil;
import com.sinosoft.ptas.dao.AnnualTargetMapper;
import com.sinosoft.ptas.entity.AnnualTargetEntity;
import com.sinosoft.ptas.service.AnnualTargetService;
import com.sinosoft.ptas.system.commom.ExceptionConstant;
/**
 * 年度目标管理接口实现
 * @author lianWuJun
 * @time   2017年2月18日 下午5:58:56
 */
@Validated
public class AnnualTargetServiceImpl implements AnnualTargetService{

	AnnualTargetMapper annualTargetMapper;

	public void setAnnualTargetMapper(AnnualTargetMapper annualTargetMapper) {
		this.annualTargetMapper = annualTargetMapper;
	}

	/**
	 * 创建年度目标
	 * @param annualTargetEntity
	 */
	public String createAnnualTarget(AnnualTargetEntity annualTargetEntity) throws BusinessException{
		if(annualTargetEntity==null){
			throw new BusinessException(ExceptionConstant.DATA_NULL_CODE,ExceptionConstant.DATA_NULL_MESSAGE);
		} 
		String id=UUID.randomUUID().toString();
		annualTargetEntity.setId(id);
		annualTargetMapper.createAnnualTarget(annualTargetEntity);
		return id;
	}

	/**
	 * 根据年度目标编号查询年度目标
	 * @param id
	 * @return 年度目标类型实体
	 */
	public AnnualTargetEntity retrieveAnnualTarget(String id) {
		if(StringUtil.isBlank(id)){
			throw new BusinessException(ExceptionConstant.ID_NULL_CODE,ExceptionConstant.ID_NULL_MESSAGE);
		}
		return annualTargetMapper.retrieveAnnualTarget(id);
	}

	/**
	 * 根据年度目标类的属性查询年度目标
	 * 如果参数为空 则查询全部
	 * @param annualTargetEntity
	 * @return 年度目标类型集合
	 */
	public List<AnnualTargetEntity> retrieveAnnualTargets(
			AnnualTargetEntity annualTargetEntity) {
		return annualTargetMapper.retrieveAnnualTargets(annualTargetEntity);
	}

	/**
	 * 根据年度目标编号更新年度目标
	 * @param annualTargetEntity
	 */
	public void updateAnnualTarget(AnnualTargetEntity annualTargetEntity) throws BusinessException{
		if(annualTargetEntity==null){
			throw new BusinessException(ExceptionConstant.DATA_NULL_CODE,ExceptionConstant.DATA_NULL_MESSAGE);
		} 
		annualTargetMapper.updateAnnualTarget(annualTargetEntity);
	}

	/**
	 * 根据年度目标编号删除年度目标
	 * @param id
	 */
	public void deleteAnnualTarget(String id) throws BusinessException{
		if(StringUtil.isBlank(id)){
			throw new BusinessException(ExceptionConstant.ID_NULL_CODE,ExceptionConstant.ID_NULL_MESSAGE);
		}
		annualTargetMapper.deleteAnnualTarget(id);
	}

}
